#! /bin/bash
#$ -q 1-day
#$ -l h_vmem=5G
#$ -t 1-3:1
#$ -M prodduturi.naresh@mayo.edu
#$ -m a
#$ -l loc2tmp=1G
#$ -V
#$ -cwd
#$ -e /data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/shapeit_logfiles_sungrid
#$ -o /data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/shapeit_logfiles_sungrid
#$ -notify
tmp=/local2/tmp/m081429/`expr $RANDOM \* $RANDOM`
cleanup () {
/bin/rm -rf $tmp
}
trap 'cleanup' USR1 USR2 EXIT
mkdir -p $tmp
cd $tmp
t1=`pwd`
t2=`uname -n`
t3="$t1 $t2"
echo $t3 > /data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/shapeit_system
k=`cat  /data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/ArrayJob_file_shapeit |head -$SGE_TASK_ID |tail -1`
/data4/bsi/RandD/Workflow/genotyping_1000genome_impute/bin/shapeit $k 
gzip snps_chr*.haps
wait
k1=`cat  /data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/Gunzip_file_shapeit |head -$SGE_TASK_ID |tail -1`
mv snps_chr* $k1
rm -rf $tmp
echo $SGE_TASK_ID >>/data4/bsi/bioinf_ext1/s112349.ucsf/UCSF_new_request_11_12_2012/temp/temp_custom/shapeit_check_jobs

